jsMath

Geršgerinovi krugovi

def g(n): A = random_matrix( RDF, n ); c = A.diagonal(); for i in range( n ): for j in range( n ): A[i,j] = abs( A[i,j] ); r = sum( A.transpose() ).list(); for i in range( n ): r[i] -= A[i, i]; p = circle( (c[0], 0), r[i], rgbcolor=(0,1,0) ); for i in range( 1, n ): p += circle( (c[i], 0), r[i], rgbcolor=(i/n,1-i/n,mod(i,2)) ); p.show( aspect_ratio=1 ); 
       
g(6)